# build stage
FROM node:16-alpine as node-stage
WORKDIR /app
COPY interact-video/package*.json ./
RUN yarn config set registry https://npm.xmov.ai/ && \
    yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ && \
    yarn config set electron_mirror https://npm.taobao.org/mirrors/electron/ && \
    yarn
COPY interact-video ./
ARG env
RUN yarn build:${env}


#production stage
# FROM nginx:stable-alpine as nginx-stage
FROM ubuntu:18.04
RUN mkdir /setup && \
    mkdir -p /opt/tiger/xmov/ && \
    mkdir -p /usr/share/nginx/html/

ADD files/start.sh /opt/tiger/xmov/start.sh
ADD files/apt.sources.list /setup/apt.sources.list
RUN DEBIAN_FRONTEND=noninteractive mv /setup/apt.sources.list /etc/apt/sources.list && \
    apt-get update && \
    apt-get install --no-install-recommends -y nginx && \
    rm -rf /var/lib/apt/lists/*

COPY --from=node-stage /app/dist /usr/share/nginx/html/
COPY default.conf /etc/nginx/conf.d/default.conf
CMD ["sh"]
